package com.muyu.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.muyu.entity.UserDbOneEntity;
import com.muyu.entity.UserDbTwoEntity;
import com.muyu.mapper.UserDbOneMapper;
import com.muyu.mapper.UserDbTwoMapper;
import com.muyu.service.UserDbService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @ClassName: UserDbServiceImpl
 * @Author: Zirun.Xin
 * @Date: 2025/3/3 16:20
 * @Version: 1.0
 * @Description: 用户数据库业务实现层
 */
@Service
@DS(value = "master")
@AllArgsConstructor
public class UserDbServiceImpl implements UserDbService {

    /**
     * 用户数据库1持久层
     */
    private final UserDbOneMapper userDbOneMapper;

    /**
     * 用户数据库2持久层
     */
    private final UserDbTwoMapper userDbTwoMapper;

    /**
     * 获取用户数据库1集合
     * @return 获取内容
     */
    @Override
    public List<UserDbOneEntity> getUserDbOneList() {
        return userDbOneMapper.selectList(new QueryWrapper<>());
    }

    /**
     * 获取用户数据库2集合
     * @return 获取内容
     */
    @Override
    @DS(value = "slave_1")
    public List<UserDbTwoEntity> getUserDbTwoList() {
        return userDbTwoMapper.selectList(new QueryWrapper<>());
    }
}
